//
// Created by Wonderful on 2025/9/18.
//

#include <iostream>
#include "Circle.h"

std::string MyGraph::Graph::ToString(){
    auto str = new std::string();
    char* buf = new char[2];
    str->append("(");
    str->append(itoa(x, buf, 10));
    str->append(",");
    str->append(itoa(y, buf, 10));
    str->append(")");
    return *str;
}

float MyGraph::Graph::Distance(const MyGraph::Graph * other) {
    return (x-other->x) * (x-other->x) + (y-other->y) * (y-other->y);
}

std::string MyGraph::Circle::ToString() {
    auto str = new std::string();
    char* buf = new char[2];
    str->append("(");
    str->append(itoa(x, buf, 10));
    str->append(",");
    str->append(itoa(y, buf, 10));
    str->append(",");
    str->append(itoa(r, buf, 10));
    str->append(")");
    return *str;
}

bool MyGraph::Circle::IsIntersect(const MyGraph::Circle * other) {
    float dis = Distance(other);
    std::cout << "dis : " << dis << std::endl;
    return (r*r + other->r * other->r) > dis;
}